import { View, Text, Image, Navigator } from '@tarojs/components'
import React from 'react';
import Taro from '@tarojs/taro';
import {Good, IndexDiyModule} from '../../utils/server.interface'
import { gotoPage } from '../../utils/tools'
import './index-sale.scss'
import RightArrow from '../../components/icon/right-arrow'
import Float from '../../components/float/float';

const defaultProps: IndexDiyModule = {
  name: '',
  moreUrl: '',
  data: [],
  type: ''
}
const LocalLife: React.FC<{data: Good[]}> =  (props) => {
  const dataColor = Taro.getStorageSync('colorData');
  return(
    <View className='index-sale-1 index-sale-box local-life-box-root'>

      <View className='title-box'>
        <View className='title'>本地生活</View>
        <View className='more' onClick={() => gotoPage('/common/local-life/index')}>
          <Text>更多</Text>
          <RightArrow />
        </View>
      </View>
      <View className='exchange-wrap-root'>
      {props.data.length > 0 && props.data.map((item: any,  index) => <Navigator key={index} className='good-item' hoverClass='none' url={'/common/limited/localdetail?locationId='+item.locationId + '&productId='+ item.id}>
        <View className='exchange-wrap'>
        <View className='lt'>
          <Image src={item.faceImg} mode='aspectFill' className='img' />
        </View>
        <View className='rt'>
          <View>
            <View className='title'>{item.title}</View>
            <View className='desc'>{item.shareText}</View>
          </View>
          <View className='price-wrap'>
            <View className='price list font-family-price' style={`color: ${dataColor.priceColor}`}>¥
              <Float value={item.salePrice} />
            </View>
            <View className='menshi list font-family-price'>市场价: ¥
              <Float value={item.originPrice} />
            </View>
            <View className='top list'>{/*销量 {item.channelSaleAmount}*/}</View>
          </View>
        </View>
      </View>
      </Navigator>)}
      </View>
    </View>
  )
}
LocalLife.defaultProps = {
  data: []
}
export default LocalLife
